package com.example.userdemo.handler;

import com.example.userdemo.util.ErrorCode;
import com.example.userdemo.util.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 统一异常处理类
 */


@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Response otherExceptionHandler(Exception e){
        log.error(e.getMessage(), e);

        return Response.failure(ErrorCode.UNKNOWN_ERROR);
    }
}
